Option Explicit

' Check arguments
If WScript.Arguments.Count < 2 Then
 WScript.Echo "Usage: embtranssform.vbs [MSI file] [MST file] [translation name]"
 WScript.Quit(1)
End If

' Connect to Windows Installer object
Dim installer : Set installer = Nothing
Set installer = Wscript.CreateObject("WindowsInstaller.Installer")

' Open database and create a view on the _Storages table
Dim database : Set database = installer.OpenDatabase(Wscript.Arguments(0), 1)
Dim view     : Set view = database.OpenView("SELECT `Name`,`Data` FROM _Storages")

'Create and Insert the row.
Dim record   : Set record = installer.CreateRecord(2)
record.StringData(1) = Wscript.Arguments(2)
view.Execute record

'Insert storage - copy data into stream
record.SetStream 2, Wscript.Arguments(1)
view.Modify 3, record
database.Commit

